module App::View
    class Edit < ItemForm
        Simplified_times = false
        
        def initialize(item)
            @simplified_times = Simplified_times
            super(item.class)

            case item
            when App::Items::Task
                @line.setText item.description
                @spinbox_hour_duration.setValue item.get_duration/60/60
                @spinbox_min_duration.setValue item.get_duration/60%60
                @spinbox_sec_duration.setValue item.get_duration%60
                start = Time.at(item.start_ms/1000)
                @start.setDate Qt::Date.new(start.year, start.month, start.day)
                @start.setTime Qt::Time.new(start.hour, start.min, start.sec)
                stop = Time.at(item.stop_ms/1000)
                @stop.setDate Qt::Date.new(stop.year, stop.month, stop.day)
                @stop.setTime Qt::Time.new(stop.hour, stop.min, stop.sec)
            when App::Items::Client
                @line.setValue item.name
            when App::Items::Project
                @line.setValue item.name
                @billable.setChecked item.billable
            end

            show
        end
    end
end
